package com.slg.android.manyanime.bean;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by E540 on 2015/3/13.
 */
public class ChannelInfo {
    /**
     * 视频id
     */
    private String videoId;
    /**
     * 名称
     */
    private String name;
    /**
     * 简介
     */
    private String intro;
    /**
     * 地区
     */
    private String area;
    /**
     * 图片
     */
    private String cover;
    /**
     * 主演
     */
    private String character;
    /**
     * 是否完结 1完结0未完结
     */
    private String isOver;
    /**
     * 当前更新至
     */
    private String curNum;
    /**
     * 共多少集
     */
    private String totalNum;
    /**
     * 类型
     */
    private String category;
    /**
     * 导演
     */
    private String director;
    /**
     * 得分
     */
    private String score;
    /**
     * 更新时间
     */
    private String updateTime;

    public static List<ChannelInfo> parseData(String json){
        ArrayList<ChannelInfo> channelInfoList = new ArrayList<>();

        try {
            JSONObject jsonObject = new JSONObject(json);
            JSONArray jsonArray = jsonObject.getJSONArray("list");
            for (int i = 0; i < jsonArray.length(); i++) {
                ChannelInfo channelInfo = new ChannelInfo();
                JSONObject data = jsonArray.getJSONObject(i);
                channelInfo.setVideoId(data.getString("video_id"));
                channelInfo.setName(data.getString("name"));
                channelInfo.setIntro(data.getString("intro"));
                channelInfo.setArea(data.getString("area"));
                channelInfo.setCover(data.getString("cover"));
                channelInfo.setCharacter(data.getString("character"));
                channelInfo.setIsOver(data.getString("is_over"));
                channelInfo.setCurNum(data.getString("cur_num"));
                channelInfo.setTotalNum(data.getString("total_num"));
                channelInfo.setCategory(data.getString("category"));
                channelInfo.setDirector(data.getString("director"));
                channelInfo.setScore(data.getString("score"));
                channelInfo.setUpdateTime(data.getString("update_time"));
                channelInfoList.add(channelInfo);
            }


        } catch (JSONException e) {
            e.printStackTrace();
        }

        return channelInfoList;
    }


    public String getVideoId() {
        return videoId;
    }

    public void setVideoId(String videoId) {
        this.videoId = videoId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getIntro() {
        return intro;
    }

    public void setIntro(String intro) {
        this.intro = intro;
    }

    public String getArea() {
        return area;
    }

    public void setArea(String area) {
        this.area = area;
    }

    public String getCover() {
        return cover;
    }

    public void setCover(String cover) {
        this.cover = cover;
    }

    public String getCharacter() {
        return character;
    }

    public void setCharacter(String character) {
        this.character = character;
    }

    public String getIsOver() {
        return isOver;
    }

    public void setIsOver(String isOver) {
        this.isOver = isOver;
    }

    public String getCurNum() {
        return curNum;
    }

    public void setCurNum(String curNum) {
        this.curNum = curNum;
    }

    public String getTotalNum() {
        return totalNum;
    }

    public void setTotalNum(String totalNum) {
        this.totalNum = totalNum;
    }

    public String getCategory() {
        return category;
    }

    public void setCategory(String category) {
        this.category = category;
    }

    public String getDirector() {
        return director;
    }

    public void setDirector(String director) {
        this.director = director;
    }

    public String getScore() {
        return score;
    }

    public void setScore(String score) {
        this.score = score;
    }

    public String getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(String updateTime) {
        this.updateTime = updateTime;
    }
}
